var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "date",
			name : "日期"
		}, {
			colkey : "warehouse",
			name : "仓位"
		}, {
			colkey : "materialNo",
			name : "物料编码"
		}, {
			colkey : "productName",
			name : "产品名称"
		}, {
			colkey : "unit",
			name : "单位"
		}, {
			colkey : "mouldNo",
			name : "模具编码"
		}, {
			colkey : "length",
			name : "长"
		}, {
			colkey : "width",
			name : "宽"
		}, {
			colkey : "height",
			name : "高"
		}, {
			colkey : "volume",
			name : "体积"
		}, {
			colkey : "clientNo",
			name : "客户编号"
		}, {
			colkey : "clientName",
			name : "客户名称"
		}, {
			colkey : "commonNo",
			name : "通用件编码"
		}, {
			colkey : "weight",
			name : "重量"
		}, {
			colkey : "perPiece",
			name : "每包件数"
		}, {
			colkey : "matingCases",
			name : "配套件数"
		}, {
			colkey : "standardCapacity",
			name : "标准产能"
		}, {
			colkey : "remark",
			name : "备注"
		} ],
		jsonUrl : rootPath
				+ '/handworkproduct_form/handworkproduct_form_findByPage.shtml',
		dymCol : true,
		checkbox : true,
		serNumber : false
	});
	$("#addFun").click("click", function() {
		addAccount();
	});
	$("#editFun").click("click", function() {
		editAccount();
	});
	$("#delFun").click("click", function() {
		delAccount();
	});
	$("#search").click("click", function() {//  绑定查询按扭

		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});

});
function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1 || cbox == "") {
		layer.msg("只能选中一个");
		return;
	}
	pageii = layer.open({
		title : "编辑手工入库表",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath
				+ '/handworkproduct_form/handworkproduct_form_edit.shtml?id='
				+ cbox
	});
}
function addAccount() {
	pageii = layer.open({
		title : "新增手工入库表",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath
				+ '/handworkproduct_form/handworkproduct_form_add.shtml'
	});
}
 function delAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择删除项！！");
		return;
	}
	layer.confirm('是否删除？', function(index) {
		var url = rootPath + '/handworkproduct_form/handworkproduct_deleteEntity.shtml';
		var s = CommnUtil.ajax(url, {
			ids : cbox.join(",")
		}, "json");
		if (s == "success") {
			layer.msg('删除成功');
			grid.loadData();
		} else {
			layer.msg('删除失败');
		}
	});
}
